local composer = require("composer")
local physics = require("physics")
local constant = require("constant")

local scene = composer.newScene()

physics.start()

function scene:create(event)
    local sceneGroup = self.view
    local bgRect = display.newRect(0,0, display.contentWidth + 300, display.contentHeight)
    bgRect.x = display.contentCenterX
    bgRect.y = display.contentCenterY
    bgRect:setFillColor(1, 1, 1)
    sceneGroup:insert(bgRect)
    --bars
    local leftBarInfo = constant.leftBar
    local leftBar = display.newRect(leftBarInfo[1], leftBarInfo[2], leftBarInfo[3], leftBarInfo[4])
    leftBar:setFillColor(0, 1, 1)
    local rightBarInfo = constant.rightBar
    local rightBar = display.newRect(rightBarInfo[1], rightBarInfo[2], rightBarInfo[3], rightBarInfo[4])
    rightBar:setFillColor(0, 1, 0)
    sceneGroup:insert(leftBar)
    sceneGroup:insert(rightBar)
    --texts
    local caption = display.newText("弹球作战", display.contentCenterX, display.contentCenterY, native.systemFont, 80)
    caption.y = caption.y - 200
    caption:setFillColor(0, 0, 0)
    local beginGameText = display.newText("开始游戏", display.contentCenterX, display.contentCenterY, native.systemFont, 60)
    beginGameText:setFillColor(0, 0, 0)
    beginGameText:addEventListener("tap", 
    function()
        local options = {
            effect = "crossFade",
            time = 1000,
            params = {
                lb = leftBarInfo,
                rb = rightBarInfo
            }
        }
        composer.gotoScene("gameScene", options)
        composer.removeScene("welcomeScene")
    end)
    sceneGroup:insert(caption) 
    sceneGroup:insert(beginGameText)
end

scene:addEventListener("create", scene)

return scene